package com.db.cm.app.controller;


import com.db.cm.app.model.PurchaseDO;

import com.db.cm.app.service.PurchaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author YOURSLIHUA
 * @since 2023-11-24
 */
@RestController
@RequestMapping("/purchaseDO")
public class PurchaseController {

    @Autowired
    PurchaseService purchaseService;

    @PostMapping("/add")
    public boolean add(@RequestParam PurchaseDO purchaseDO) {
        return purchaseService.add(purchaseDO);
    }

    @PostMapping("/delete")
    public boolean deleteById(@RequestParam PurchaseDO purchaseDO) {
        return purchaseService.delete(purchaseDO);
    }

    @PostMapping("/update")
    public boolean update(@RequestParam PurchaseDO purchaseDO) {
        return purchaseService.delete(purchaseDO);
    }

    @PostMapping("/selectAll")
    public List<PurchaseDO> selectAll() {

        return purchaseService.selectAll();
    }

    @PostMapping("/selectById")
    public PurchaseDO selectById(@RequestParam PurchaseDO purchaseDO) {
       return purchaseService.selectById(purchaseDO.getGoodsId());
    }

}

